made search method a lot safer