#74 bugfix, refactoring