re-ordered some parts of the script and added more comments