fixing uninitialised n_grid value