Preprocess data function created