this looks suspect - isn't the closing } for the for and not for the if, hence the original intendation was the correct one?