fixing the cookie logic