using function to determine if to cache or not