Checkout algorithm