fix issue 1931: preserve vars in grid search
Merge pull request #569 from ilvalle/grid-search-fix

fix issue 1931: preserve vars in grid search