Cleaned up the script a bit