If deepcopy works fine, then why did you change this code?