Refactoring and option to clear cookies