abstract html rendering into a single function