fix state not getting updated to new state