Refactor: separated logging concern into its own method