update time interval threshold and add additional check condition
fix divide by 0 bug