On the canonical ring of algebraic varieties