refactored printing grid