Reverted back to working code without manipulating the padding bit.