Replace search logic