Fixed error on cache function