fixes #5849, thanks bitpshr (Paul Bouchon)