secondo me potresti provare con un ciclo while...