works on small data. going to valgrind