Improved bash script that runs automatically.