SERVER-6376 small refactor to eliminate redundant code