Fixed issue caused when cache is empty

Fixed an issues with an exception thrown when the cache is empty.