undefined value of emails was causing issue