refactor queueing system (1/2)