Change if statement causing error