crazy and rotr implementation