Fixed escaping logic