implementing a queue as a procedure with local state