use opts in write function

it's important to use prevExist vs prevValue for keeping leadership :P