code from tharindu_downloadCSV branch