learning some algorithm