updated to use result.error instead