Ok,
ho apportato le modifiche che mi hai detto e adesso funziona bene.