added braces to all ifs