Optimization update

Updated the code for the use of variables