modified search function