Refactoring attempt

HEre's my attempt at refactoring this controller.