Implemented more clever interval calculation