minor refactoring. Added fetchOneThenReplace support.