@zjc and @ucos-xiu 's solution