Refactor runInNode