lots of refactors