remove controller and refactore code