Removed the use of if statements

Somewhat more efficient way
Merge pull request #1 from japborst/master

Removed the use of lots of if-statements