updated sample code for linked list