Polishing

a) try to get updateF() value first; only if it does not fail, copy the array, etc
b) there is a huge code repetition here, get rid of it.

for the b) I think, you can simply use _insertWith?