still having issues with sum_r, sum_x in simulation