added save functionality to templates