compress these 3 if statements into 1