imporve cp.sh and clipping algorthiem