Inserts need to be inside the foreach.