Fixed code to create grid