Can't retrieve lastResults during searchFunction

Hi, I’m trying to use the previous search result to modify the search. While paused mid searchFunction, using the console I can see the previous results in search.helper.lastResult. However, when I try to access that within the function it is undefined.

Example returning undefined:

var instantsearchOptions = {
			searchFunction: function (helper) {
				if (helper.state.query === '' && !algoliaConfig.isSearchPage) {
					$('.algolia-instant-replaced-content').show();
					$('.algolia-instant-selector-results').hide();
				} else {
					helper.search();
					$('.algolia-instant-replaced-content').hide();
					$('.algolia-instant-selector-results').show();
				}
                    console.log(search.helper.lastResults.query); \\ this throws Uncaught TypeError: search.helper is null
			}
		};

What am I missing?

The search.helper.lastResults object looks ok and has the info I want but the helper.lastResults object is null, hence why I am not trying to use that. Is there another way to access lastResults?