fixed parseTemplate core method