Use list instead of deque