changing old code to accept new dataframes