fixed bug when idx not defined by template context