modified cp function 1