added a cloud funtion to fix a db error