rewriting the controller a little