fix bugs when search used id in lambda that has been shadowed