added template selection and ajax update