Refactoring disconnect event