added in if and else, removed excess space