Fix substitute function for HTML entities