[CHG] refactor code, improve output