refactor way to store cookies
clean code and add examples of validation