Refactor hooks