length control & final data prepare