common code by charn.