Refactored ApplicationController.cs