refactored grid drawing flow