Fixes the issue with select/each

Fixes #9436