removed some duplication in application controller