added escapeHTML where needed