bugfix: if loop variable is nil, return empty result
bugfix: fixed invalid Buffer usage
bugfix: base_tag substitution was malformed