scratch data and preprocess template