Fixed state checking bug