Js refactor

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

I think this should be in another package. I still think put it into the service package. But utils is not the right place.