UP-4006: Refactoring out methods for readability, adding a log statement  and commenting based on review feedback.