modified the work with cookies