Fix a bug in ribbon_twist function