changed the positions of the  expressions inside the if sats