some tweaks to the algo