removing last of the html (error checking)