è bastato aggiungere un break e ora funziona