Fixed grid creation to use more efficient for loop