add in error checking and reporting