better handling of cookies