getting alerts to work correctly and refactoring controllers to be more modular