change template structure to reduce redundant code
add "set -e" to run.sh