Refactored tanspose code to make decoding more easy