cleaning up script and adding some more comments