I think the linked list works. Please test...