better handling of errors for sandbox