Code optimization

Instead of lot of code now we have code reuse using initPingState() and
startPing()