Merge Qi's code.