refactor hooks