Added firebase write functionality