Fixing bug in linked list