endianess bug corrected