Refactored ping scripot