more idiomatic code and a logical fix
Merge pull request #2 from kargakis/master

more idiomatic code and a logical fix