refactored using of config, improved logging