refactored code for traffic per queue