refactor to allow for code reuse with mare and tbb