working random caching