rewrite the product and category checks to be easier to read.