added the static header data and remaining length algorithm