Refactor for separation of concerns