Bug in the search mechanism, it is not stopping on solution