refactor application directory code