Refactor receiving a packet