bug fix and template fix