Add optimization code