Generic atomic update code

Couldn't resist doing a little cleanup before writing a test.
maybe have this function take the interface in?  That way you don't have to rely on scope binding like you do above.