refactored pingidm.sh