updated much of new code for new grid