Simplify the code computing cookies