fixed sorted_df reference