def fix bwt