replace Dequeue with Stack