Re-added Trent's refactoring