improve document.cookie implementation