Improved add to cart function