new tensor code