Enhance search function

yet to test, as the formatter needs to be resolved first
Refactor search
Added new test case for enhanced search