Kaiyu's code