changes for error handling when outputting HTML