fix crash in XAPI.js