Fixes #1918
Refactoring