changed add_state_hook to set_state_hook