more refactoring and moving around