Some refactoring on the base controller