construct cache more efficiently