Improve for loops in cookieUtils