Jinwen & hongmin: refactor code