works for all data points, valgrind shows no memory issues