second version

uses cache correctly