used new search method because this wouldn't run sql in loop
add new test code