refactor & logging enhancment