implementation of Twist transform