Refactored if statements

Hopefully I didn't break anything.