queues refactoring