modified to run for all chromosomes