improve plot_history