apply the patch from joyxu github