Can you maybe check for a constant as state? Since state 0 is a bit like a magic value at this point