Improved algo, searches till root-n only