changed the if conditions