Refactoring to files