Fixed bug in export function