implemented read and acceptPacket, along with helper functions