generalizing the script a little