implements caching TODO in localgridsearch