updated cache code