Jiamin's initial code