fixed plot_error method