generic enumerable refactor