fixed the bug with last interval