Improved data export function