Added comments for better readability
changed from bash to sh which mshould result in better compatibility on systems
without bash
added comments