improve checkout logic