First attempt at refactoring hooks again