refactoring of base controller