cached solve implementation ready for testing