Fix the dequeue to get the correct last node