refactored results with NaN array and empty arrays to fit the results of R