refactored controller method, added private method and took away excess variables