Working version of minimize in document.toObject, negative speed impact