added change template logic