fixes issue #1888

Fresh PR, really messed up my fork with rebase master accidentally... sorry