update stack and linked list