improve search function