Refactored transaction logging to its own method