Fixed a bug with state generator