CR changes: removed Math.random() and used "round-robin" instead