further simplify nested if statements in theme code