add error handling and processing