fixing javascript bugs that caused no emails to populate database