fixing state change bug