Improved ping code