sudo code for optimizer