rewrote by Liuyicong