Fixed output formatting and error handling.