refactored, switched to data point (x, f(x)) format