patch from @dhonn