using a deque to keep track of lines