some progress
much improve algorithm