made algorithms stable