add free_list() to release the memory of a list