implement registerHook, closes #3