Replaced if/then witch switch/case

- replaced if/then with switch/case
- optimized code a bit
Merge pull request #9 from RiZKiT/patch-5

Replaced if/then witch switch/case