refactoring queue creation