refactored the output