Remove code duplication in ApplicationController

Remove code duplication in `ApplicationController`