refactoring
logging improved