cookie refactor