fixing a bug on state change