added escaping into the logic