refactoring code
Merge pull request #5617 from pana1990/patch-1

refactoring code