added code to check perferences stored in the cookie