added error checking/reporting