Fix indexing for history check