fixed cookie logic