did some more organizing and refactoring