Made a cloud function which will send email of invitation and upon successful send it will update a map object field but for some reason it is only working for the last object n