fixed duplicated cache code