replace stack to deque