Sync the code with Ming's code, change handle variables