solutions/max_kaskevich/4: some refactoring.