stir algorithm bug fix