result passing refactoring