add config.h for configuration and do refactoring