Implemented copyTo function.