lab1 optimization