Code refactoring.
Merge pull request #1429 from namusyaka/remove-duplication

Code refactoring.