added some algorithm