Updated method to create output data frame