Now using queue as an output container
small refactoring