changed sendPacket function for more usability