refactor delay