changed template and added new fuctions