Fixed the state counter