redo declared and freed in the right place