Refactor hook api