refactoring, fixing #6