Refactoring controllers and hooks