search function (needs to be revised)