fix swap/endianness bug