implemention of common algrithoms