refactored a ton