Prabin - refactored the script a bit to have a few assertions. Started getting the here docs out of the script