Unused variable insertCollection

I kept getting an error about insertCollection being undefined. When I looked into it, I noticed insertCollection was set to 'undefined' and never used in this function. As a result, it wasn't properly throwing an error when it should have because it kept getting stuck on this undefined variable.