per Srikanth's suggestion, please use set -e and set -u