Main.sh updated with functions