upgraded data_preparation()