working linked list function for our project