Bringin plotting of diagnostics inside foreach loop