Work in progress on #9

Work in progress...
#9 - needs testing
Fixed minor bug
Merge pull request #18 from milivojm/untested

Untested