Simplify grid code