SAFE_CAST bug fixed