shortened the first 2 IF statements