Issue 2227 fix

Replace the old PR #2427 , fix the issue #2227