You could factor out `Object.keys( global.instances[ namespace ].clients ).length > 0` into a function called `ClientsConnected` and the opposite in a function called `NoClientsConnected`.