Make subtemplate get more robust