move code for clearity
Update managing of cache