beforeSearch fix