refactor; work on cookies