add error handling and output