Se usi Math.round() ottieni un numero che va da 0 al massimo indice, devi usare Math.float() per avere un numero fra 0 e l'indice -1