Made function to return intervals