packet algo working