Refactor ApplicationController