refactoring an odd case of code organization