Js refactor

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

Why don't you do the amber stuff in the method too?