4 times "elseif" is not the way 

and precalc. value sometimes help if well commentent
Merge pull request #154 from wopot/patch-1

4 times "elseif" is not the way