refactoring and add configuration file feature