made the script a little more flexible