check config and little refactoring