error checking

added error checking