Patch at #2 looks good to me , but there is also duplicate code for updating ...