moved some code around
fixed the single/double curly braces problem