modifed search funtion