These 5 lines are equivalent to:  silences_pointer = (silences_pointer % #silences) + 1

The above is more readable to me, but maybe not for everyone, do what you want here.