added braces to if/else statements and other fixes