add "set -o pipefail" to ensure that errors are propagated