use a queue rather than a list. fixes #12069