Refactored grid row loops