Error messages added to cp function and comments added