refactoring
tests pass :)
merged