refactoring some of the crap out