more refactoring. Throw it all in the application_controller!