created insert method for linked lists