Final version for Optimization