refactor my-add-mode-to-hooks function