refactoring shopping cart and checkout logic