templade code improvements