Fix empty history bug