write html based on current state