added some general algorithms