Update linked list template with loop detection