add some comment and rewrite stat as class