logging refactoring
fixed logging bug