clean up for loop for switching endian