updated code to take into account different redshifts