new code to generate cm
big dev for cma