implementation of the special solve function with caching
implementation of the special solve function with caching