Refactoring to move functions into their own files