add search test case and optimised code accrodingly