Adjusted searching function