Fixes #4131

A slight refactor.