Refactored and updated log for problem 12