refactored more of the code to accomplish proper separation of concerns