Perform some refactoring on getAllQueues