Is this exactly how you have your script? 'Cause (if I'm not completely blind) everything is correct in there.
EDIT: Make sure you have your brackets ({ and }) correctly in those parts that you left out when posting here. It's likely to be a bracket-mistake.
EDIT: Make sure you have your brackets ({ and }) correctly in those parts that you left out when posting here. It's likely to be a bracket-mistake.