refactoring ping