changed api.call interface to return error and result