optimized grid drawing