adding some grid logic