better regex on templates