moved from list.pop(0) to deque.popleft()