Refactored script and added logging. Also added log to .gitignore.