fix for edge cases and removed some unnecessary code
Merge pull request #4 from rickytux/refactor

fix for edge cases and removed some unnecessary code