Moved core business logic into a service layer