refactor displaySearchGrid and related function to remove multiple calls