refs #19.  optimize the implement.

merge with trunk