Started: extracting out HTML generation logic.