Guard against race condition with next / prev

The logic added may seem redundant, but guard against index out of range
occurrences when cycling rapidly through a group with numerous items.