update grid function