Fixed error when the hook gets called.