refactored application controller