fix Template infinite loop