Refactor controller to be stateless