#26 bugfix, refactoring