finished controller refactoring