Adding function to count ranges in an array in order to simplify code.