refactor basecontroller