reorganized code, started on HTML parsing