algorithm was working, but gnuplot wasn't