refractored Template