cookie() method refactored