formatting and error handling