refactoring OPT with hooks