Added function to calculate the interval + minor changes