updated to support different template tag types