Refactored sample to make following the tutorial easier.