a backup version with many test code.
refactor and format code.