wrapped the histogram-making for loop within a tryCatch function in case there are errors