Factorize some code
Round-Robin scheduler