update template
add more logic