refactored LongToWide using merge instead of cbind