Add code for optimization