Added grid building functions