add some functions
remove the repeated end