Fixed escape function