more modularization and clean clode