Add { to the for loop as its not a single statement loop anymore with nested if condition. ditto to all places.