dding main function