Code refactoring by YongWen