Refactored and modified output