fixing and refactoring autoSearch method

Signed-off-by: Douglas Silva <douglas_hss@hotmail.com.br>