refactoring and made pings threaded