remove cookie and fixed scope of variable