better appendHTML implementation