refactoring controller api