refactored icmp functions