add saveas function and improve export function