Add service layer, refactoring