Add command for multiple queues, remove some code duplication