add a function to do smart ping