fix for issue #1860

Hello @jirikuncar, here is the proposed patch.