tidy script a bit