Finished the grid math