Fixed bug where linked list was cyclical