Fixed a logic error with packet sending