Coded merge logic for grids