trout refactoring