#75 bugfix, refactoring