Added checks in the handlepacket to check the type of packet