Fix IndexError in ring.py