refactored some more