Deepcopy added to pass query to sav and csv