fix cdupan function.