Refactoring to PacketHandler