search function improved, but really quite ugly