set the html header correct
add additional cases for unsuccessful connection