properly. Contributed by Ming Ma. (cherry picked from commit 4efdf3a979c361348612f817a3253be6d0de58f7)