Added curly braces to if statements