if statement is getting in the way