Fixed off-by-one history bug