add grid logic