Added basic grid generation logic