refactor checkout