moved controller code into its own controller class