Fixed a small bug in my new version of this script.