Balaban algorithm implementation