Fixed a bug in state lookup