this is the patch suggested by @ilesinge in #784 just opened the PR so it would be merged anytime soon