refactor application controller