added list_destroy function, checked for memory leaks