Updated code to ensure that cats loop instead of throwing an error when reaching the final cat in the set