Fix arraylist out of bounds error