Merge "Fixing optimization logic" into main