finish refactoring to handle queues