improve history saving