pre-process data