code refactoring for bug 928237
Merge pull request #283 from xdchen/bug928237

code refactoring for bug 928237