rewrite whole module and  add some new functions