bug fix bead sort