filter_data function

Prepare input data