added free(list) call due to valgrind fail.