fix scope issue in isNewSearchNeeded function