refactored like a boss