refactoring hooks and hook system