did some algorithm tweaking