bugfix and add some function