Removed the use of if statements

Somewhat more efficient way