P089: improved solution