SERVER-9038 Simplified logic according to codereview