add error handling conditions