added if - clauses in the cp commands