Changed place to throw InvalidPacketException