reduce redundancy in if statement grammar