updated template based on Chris's code