working now, have some algorithm problem