When checing for a new packet, check the last index first

This change should lower the execution time of this functuion.