Fixes #23

Please review this code and if you don't like it open another issue requesting refactoring.