base code for linked list