A tutorial solution code with some changes.