fixed emailing functionality to allow multiple recipients. reduced redundancy in js