Js refactor

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

I really cant think of an elegant name. Its pretty simple to push it into a new unit later if we think of a good one.