add some functions and clear template