patch from @jzbontar