refactoring and changes to ping