A more proper fix of commit 163706a6a7fc5d734233a5808f5df386fc8a0f3b.