Improved the fix for issue #1599 based on comment @dominicdesu