improved roundRobin for easier import into other functions