Added API error check with option callback function