Yefei's refactoring