added several error handling cases. assignment complete.