implementation now uses collections.deque and FunctionThread is sketched out