implemented inversion & caching functions