rewriting input rubix