refactor mxapi