interval calculation