Optimization algorithms for generator and checker function