added error checking all tests passing