function to calculate which intervals are allowed