refactor using stubs