fixed backtracking bug by adding densities to state copy