script to download history data