Prima di fare il for each di ogni variabile verifica quello che vuoi e poi, se OK, entri nel for