#983 fix as recommended by @fjirari

Fix for issue #983 as recommended by @fjirari
Works on Windows, but cannot test for other OS.