fix history end bug