added an automated way to get interval