Rewrite to simplify cart functionality