professor Wang's code