Removed unecessary imports.
Added condition to prevent passing falsy values to disconnect.