Factor out a function into it rightful file