Move mesh creation outside the loop