Separated the angular controller from the business logic