move check out of loop
pas start and end
fix in packet length calculation