deep copy function for linked lists added