Re-assign last after setting next to maintain the linked list.