bug fix with template code