(#129) - smarter upsert, only updates doc when necessary