Slightly updated grid drawing logic