add automatical clipping function