added packetloss function