refactor isDone pattern