Move code that hides search results into own method

Change-Id: I61bd717d5d6a8c67dce556a284a721688810ff19