restructure pad cookie code