using DOM instead of string building