Js refactor

Pulls the business logic out of the controller and into a utility class

Is it really a 'service' though?