refactoring on queue