Refactor html page building - duplication removed