crop and threshold script