Removed the use of lots of if-statements

Somewhat more efficient way. Spotted this tiny thing and thought to change it for you :)