got algo working