update code for c and d proj.median