changed the way emails are read from database