refactor, prep for threads