modify template to automatic detect