bit of refactoring, close #44