Refactor using interval