Broke down the script into function calls. Added check for pre existing ...

...build in master branch