This week's book giveaway is in the Mac OS forum. We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line! See this thread for details.
Please SearchFirst (<- click), the same question has already been raised here.
Also UseCodeTags (<- click) when posting your code. With proper indentation and code tags your code will be much easier to read and that will certainly increase your chances of getting a good answer! I have added them for you this time.
Welcome to the Ranch!
EDIT: Also make sure you post SSCCE. There were parentheses missing in your code.
The quieter you are, the more you are able to hear.