Changed the check for a succesfull cp by checking it's result code.