refactored code, support for html
initial version