better preprocessing handling in melt_dataframe