Caliers algorithm implementation (not finished)