Extract duplicates into separate functions.
Merge pull request #13 from it-vecherka/examples-refactoring

Extract duplicates into separate functions.