Thanks AppleFritter,
I will surely try and use your suggestion .. but the problem here was that i generate the header on the fly based on the input given ..
if the input was say 8 .. the header could be
7 6 5 4 3 2 1 0
and if the input was 15 the header could be
15 14 ... 0
can you use your solution for this .. ?