adding apply_grid function
starting to integrate grid into flow