fixing issue with copying from deque