moved code in templated example around for readability.