added error checking to c lib

fiddled with html