Refactor the sample code to be much easier