The previous code went outside of the list bounds because the modulo operator has a higher priority than the addition one.