minor algorithm effectivness improvments