moved some code into script.sh