Reformatting code and adding brackets to if statements