19 refactor code

Fixes #19.