Refactoring separating logic in files