small algo tweaks