improve lesson 7.1.2 solution