refactoring and controller api