export script; basically work but still incomplete