#149 done with some simple refactoring