redefinition of data caused problem. use a temp file