Added th tag logic and cleaned up conditional statements