fix bugs and add some founction