Fixing a bug in hooks