Refactor reconnectiong