private function convertWriteConcernOptions(array $options)
    {
        if (isset($options['safe'])) {
            $options['w'] = ($options['safe']) ? 1 : 0;
        }

        if (isset($options['wtimeout']) && !isset($options['wTimeoutMS'])) {
            $options['wTimeoutMS'] = $options['wtimeout'];
        }

        if (isset($options['w']) || !isset($options['wTimeoutMS'])) {
            $collectionWriteConcern = $this->getWriteConcern();
            $writeConcern = $this->createWriteConcernFromParameters(
                isset($options['w']) ? $options['w'] : $collectionWriteConcern['w'],
                isset($options['wTimeoutMS']) ? $options['wTimeoutMS'] : $collectionWriteConcern['wtimeout']
            );

            $options['writeConcern'] = $writeConcern;
        }

        unset($options['safe']);
        unset($options['w']);
        unset($options['wTimeout']);
        unset($options['wTimeoutMS']);

        return $options;
    }