Merge LinJun's code