Fixed code duplication.
Merge pull request #1 from Kolyunya/master

Fixed code duplication.