Adding key checks

Hi, a function being added in a prototype somewhere was causing the CSV to have a problem downloading in my case.  I've fixed this so my code works, thought I'd send you a pull request in case you want to incorporate.