refactor the code under 'controller' dir