some standard algorithm implemnetation