Refactored logging and added better printing format