added cookie handling