Stop counter potentially going past size of ArrayList