Completed the functions for linked list