fix state indexing